#ifndef __OSENSOR_H__
#define __OSENSOR_H__

class oSensor;
class oBody;
typedef delegate<void (oSensor*, oBody*)> oSensorHandler;

class oDLL oSensor: public CCObject
{
public:
	oSensor(oBody* owner, b2Fixture* fixture);
	~oSensor();
	PROPERTY(bool, _enable, Enable);
	PROPERTY(uint32, _tag, Tag);
	PROPERTY_READONLY(oBody*, Owner);
	PROPERTY_READONLY(b2Fixture*, Fixture);
	PROPERTY_READONLY_REF(vector<oBody*>, SensedBodies);
	bool contains(oBody* body);
	oSensorHandler bodyEnter;
	oSensorHandler bodyLeave;
	static oSensor* create(oBody* owner, b2Fixture* fixture);
private:
	void add(oBody* body);
	void remove(oBody* body);
	void clear();
	vector<oBody*> _sensedBodies;
	oBody* _owner;
	b2Fixture* _fixture;
	friend class oWorld;
};

#endif